#ifndef _FIG_LEVEL_H_
#define _FIG_LEVEL_H_

#include "fig_Pickup.h"
#include "fig_enemy_craft.h"
#include "fig_enemy_formationcraft.h"
#include "fig_flyingpath.h"
#include "fig_shakescreen.h"


#include "ui/ui_manager.h"
#include "math/vec2.h"
#include <vector>

class FIGBackground;
class FIGEnemyManager;
class PVUShadow;
class FIGBullet;
class FIGLifeObj;

class FIGLevel 
{
public:


	const static float								ENEDLESS_SPAWN_SMLL_MAX_DURATION;
	const static float								ENEDLESS_SPAWN_MINIBOSS_MAX_DURATION;
	const static float								ENEDLESS_SPAWN_BOSS_MAX_DURATION;

	const static float								ENEDLESS_SPAWN_SMALL_MIN_DURATION;
	const static float								ENEDLESS_SPAWN_MINIBOSS_MIN_DURATION;
	const static float								ENEDLESS_SPAWN_BOSS_MIN_DURATION;

	const static float								ENEDLESS_SPAWN_SMLL_ACCELERATE;
	const static float								ENEDLESS_SPAWN_MINIBOSS_ACCELERATE;
	const static float								ENEDLESS_SPAWN_BOSS_ACCELERATE;

	


	struct EnemyInfo
	{
		std::string									Name;
		
		int											TimeAfter;
	
		int											Duration;		
		int											Count;
		float										DelaySpawn;
		float										SpawnPositionX;

		FIGEnemyCraft::ENEMY_TYPES					EnemyTypeEnumInt;	 // normal , miniboss , boss , etc..
		unsigned long								NameCRC;
		FIGPickup::PICKUP_TYPES						SpawnTypeEnumInt;
		FIGFlyingPath::PATH_TYPE					FlyingPathEnumInt;
		FIGEnemyFormationCraft::FORMATION_TYPE		FormationEnumInt;

		EnemyInfo();


	};

	FIGLevel(
				const std::string& Level_BG_Main_Name,
				const std::string& Level_BG_Name,
				const std::string& Level_Enemy_Name
				);
	~FIGLevel();
	
	void							Render(const math::Vec2& Offset, float Scale);	
	void							RenderDebug(const math::Vec2& Offset, float Scale);
	void							RenderShadow(const math::Vec2& Offset, float Scale);
	void							Tick(float dt);	
	
	bool							HitTest(FIGBullet* pBullet);
	FIGLifeObj*						HitTest_Laser(const math::Vec2& StartPos, 
															float Width,
															math::Vec2& HitPos
															);
	
	void							DoDamangeToAll(float DamageAmount);
	void							Clear();

	void							Load(
											const std::string& Level_BG_Main_Name,
											const std::string& Level_BG_Name,
											const std::string& Level_Enemy_Name);

	FIGLifeObj*						GetTopidoTarget(FIGBullet* pBullet);
	bool							IsEndless() { return m_IsEndless; };
	void							Shake(float Intensity);

protected:

	
	void							StartNewLevel();
	void							Tick_Endless(float dt);
	void							SpawnEndlessSmall();
	void							SpawnEndlessMiniBoss();
	void							SpawnEndlessBoss();
	void							SpawnRandomSmall();


	std::vector<FIGBackground*>		m_Backgrounds;	
	std::vector<EnemyInfo*>			m_EnemyInfos;

	int								m_NextEnemyIndex;
	float							m_Duration;

	PVUShadow*						m_pShadow;
	float							m_OffsetY;
	float							m_ConversationDelay;


	bool							m_IsEndless;
		
	float							m_Endless_SpawnSmall_Counter;
	float							m_Endless_SpawnMiniBoss_Counter;
	float							m_Endless_SpawnBoss_Counter;

	float							m_Endless_SpawnSmall_Duration;
	float							m_Endless_SpawnMiniBoss_Duration;
	float							m_Endless_SpawnBoss_Duration;

	float							m_Random_SpawnSmall_Counter;



	bool							m_bIsFirstTimeLoading;
	FIGShakeScreen					m_ShakeScreen;


};



#endif